package com.lg.online_shop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lg.online_shop.entity.GoodCategory;
import com.lg.online_shop.vo.CommonChartData;
import com.lg.online_shop.vo.Overview;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface    GoodCategoryMapper extends BaseMapper<GoodCategory> {

//    通过种类分组查询销量
    @Select("SELECT \n" +
            "    good_category.title as name, \n" +
            "   COUNT(good_category.title) as value\n" +
            "FROM \n" +
            "    good \n" +
            "JOIN \n" +
            "    good_category ON good.g_category_id = good_category.id \n" +
            "JOIN \n" +
            "    orders ON good.id = orders.g_id  where orders.status = 1\n" +
            "GROUP BY \n" +
            "    good_category.title;")
    List<CommonChartData> selectCountWithCategory();
}
